﻿<?php 
//error_reporting(0);

include 'conn.php';
include 'common.php';?>
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>考试查询</title>
<body>
<div class="container">
<div class="nav_header">
<?php include 'head.php';?>
</div>
<div class="main_cj_content">
<p class="welcome">考试详情:</p>
<hr>
<br />

<?php
if(getget('examid'))
{
	$exam_id=getget('examid');
	$count_exe="select count(*) from grades where exam_id=".getget('examid');
	$count_rs=mysql_query($count_exe);
	$count_row=mysql_fetch_array($count_rs);
	$rowcount=$count_row['count(*)'];
	if($rowcount>0)
	{
	
	
	$exe="SELECT t1.sx,t1.yw,t1.yy,t1.wl,t1.hx,t1.sw,t1.ls,t1.zz,t1.dl,
		(coalesce(t1.sx,0)+coalesce(t1.yw,0)+coalesce(t1.yy,0)+coalesce(wl,0)
		+coalesce(hx,0)+coalesce(sw,0)+coalesce(ls,0)+coalesce(dl,0)+coalesce(zz,0)) 
		as sumscore,t2.realname,t2.class,t2.id  FROM grades as t1 ,users as t2 where  t1.userid=t2.id and exam_id=".$exam_id." order by sumscore desc";
	$rs=mysql_query($exe);
	echo "<table border=1 class='search_result'>";
	echo "<tr><td>姓名</td><td>学号</td><td>数学</td><td>英语</td><td>语文</td><td>物理
	</td><td>化学</td><td>生物</td><td>历史</td><td>地理</td> <td>政治</td><td>总分</td><td>班级</td><td>排名</td></tr>";
	$order=1;
	while($row3=mysql_fetch_array($rs))
	{
	
		$sx=$row3['sx'];
		$yw=$row3['yw'];
		$yy=$row3['yy'];
		$wl=$row3['wl'];
		$hx=$row3['hx'];
		$realname=$row3['realname'];
		$sw=$row3['sw'];
		$ls=$row3['ls'];
		$dl=$row3['dl'];
		$zz=$row3['zz'];
		$sumscore=$row3['sumscore'];
		$class=$row3['class'];
		$userid=$row3['id'];
		echo "
		<tr><td>".$realname."</td><td>".$userid."</td><td>".$sx."</td><td>".$yw."</td><td>".$yw."</td><td>".$wl."</td><td>".$hx."</td><td>".$sw."</td><td>".$ls."</td><td>".$dl."</td><td>".$zz."</td><td>".$sumscore."</td><td>".$class."</td><td>".$order."</td></tr>";
		$order=$order+1;
	}
	echo "</table></fieldset><br /><br /><br />";
	}
	else 
	echo "<p>对不起，这次考试还没有导入成绩!</p>";
}
?>